﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:localUI="clr-namespace:Wallace.IDE.Framework.UI">

    <Style x:Name="ChromeTabItemStyle" TargetType="{x:Type TabItem}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TabItem}">
                    <Grid>                                                
                        <Border Name="Border"
                                Background="Transparent">

                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto" />
                                    <ColumnDefinition Width="Auto" />
                                </Grid.ColumnDefinitions>

                                <ContentPresenter x:Name="ContentSite"
                                                  Grid.Column="0"
                                                  Margin="6,3,3,3"
                                                  MaxWidth="200"
                                                  VerticalAlignment="Center" 
                                                  HorizontalAlignment="Left"
                                                  ContentSource="Header"                                                  
                                                  RecognizesAccessKey="True">
                                    <ContentPresenter.Resources>
                                        <Style TargetType="{x:Type TextBlock}">
                                            <Setter Property="TextTrimming" Value="CharacterEllipsis" />
                                            <Setter Property="HorizontalAlignment" Value="Left" />
                                            <Setter Property="ToolTip" Value="{Binding Text, RelativeSource={RelativeSource Self}}" />
                                        </Style>
                                    </ContentPresenter.Resources>                                    
                                </ContentPresenter>

                                <Canvas Name="CloseButton"
                                        Grid.Column="1"
                                        Margin="3,0,3,0"                                        
                                        Width="16"
                                        Height="16">
                                    
                                    <Canvas.Style>                                        
                                        <Style TargetType="{x:Type Canvas}">
                                            <Setter Property="Background" Value="Transparent" />
                                            <Style.Triggers>
                                                <Trigger Property="IsMouseOver" Value="True">
                                                    <Setter Property="Background" Value="#52B0EF" />
                                                </Trigger>
                                            </Style.Triggers>
                                        </Style>
                                    </Canvas.Style>
                                    
                                    <Canvas.InputBindings>
                                        <MouseBinding MouseAction="LeftClick" Command="{x:Static localUI:Commands.CloseTabItem}" />
                                    </Canvas.InputBindings>
                                    
                                    <Line X1="4" Y1="4"
                                          X2="12" Y2="12"
                                          Stroke="White"
                                          StrokeThickness="2"
                                          StrokeEndLineCap="Flat"/>

                                    <Line X1="12" Y1="4"
                                          X2="4" Y2="12"
                                          Stroke="White"
                                          StrokeThickness="2"
                                          StrokeEndLineCap="Flat"/>                                    
                                </Canvas>
                                
                            </Grid>
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="localUI:ChromeTab.ShowCloseButton" Value="False">
                            <Setter TargetName="CloseButton" Property="Visibility" Value="Collapsed" />
                        </Trigger>
                        <Trigger Property="IsSelected" Value="True">
                            <Setter Property="Panel.ZIndex" Value="100" />
                            <Setter TargetName="Border" Property="Background" Value="{StaticResource HeaderBackgroundBrush}" />
                            <Setter Property="Foreground" Value="{StaticResource HeaderForegroundBrush}" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="Border" Property="Background" Value="Gray" />
                            <Setter Property="Foreground" Value="Black" />
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" Value="True"/>
                                <Condition Property="IsSelected" Value="False" />
                            </MultiTrigger.Conditions>
                            <MultiTrigger.Setters>
                                <Setter TargetName="Border" Property="Background" Value="{StaticResource HeaderHotTrackBackgroundBrush}" />
                                <Setter Property="Foreground" Value="{StaticResource HeaderHotTrackForegroundBrush}" />
                            </MultiTrigger.Setters>
                        </MultiTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="ChromeTabControlStyle" TargetType="{x:Type TabControl}">
        <Setter Property="OverridesDefaultStyle" Value="True" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="ItemContainerStyle" Value="{DynamicResource ChromeTabItemStyle}" />
        <Setter Property="TabStripPlacement" Value="Top" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TabControl}">
                    <Grid KeyboardNavigation.TabNavigation="Local">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" Name="RowDefinition0" />
                            <RowDefinition Height="*" Name="RowDefinition1" />
                        </Grid.RowDefinitions>
                        
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" Name="ColumnDefinition0" />
                            <ColumnDefinition Width="Auto" Name="ColumnDefinition1" />
                        </Grid.ColumnDefinitions>
                        
                        <StackPanel Name="HeaderPanel"
                                    Grid.Row="0"
                                    Grid.Column="0"
                                    Panel.ZIndex="1" 
                                    Margin="0,0,4,0" 
                                    Orientation="Horizontal"
                                    IsItemsHost="True"
                                    KeyboardNavigation.TabIndex="1"
                                    Background="Transparent" />
                        
                        <localUI:TabOverflowButton Name="OverflowButton"
                                                   Width="16"
                                                   Height="16"
                                                   VerticalAlignment="Bottom"
                                                   Grid.Row="0"
                                                   Grid.Column="1" />
                        
                        <Border Name="Border" 
                                Grid.Row="1" 
                                Grid.Column="0"
                                Grid.ColumnSpan="2"
                                Background="White" 
                                BorderBrush="{StaticResource HeaderBackgroundBrush}" 
                                BorderThickness="0,2,0,0"
                                KeyboardNavigation.TabNavigation="Local"
                                KeyboardNavigation.DirectionalNavigation="Contained"
                                KeyboardNavigation.TabIndex="2" >
                                <ContentPresenter Name="PART_SelectedContentHost"
                                                  ContentSource="SelectedContent" />
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Foreground" Value="Gray" />
                            <Setter TargetName="Border" Property="BorderBrush" Value="Gray" />
                        </Trigger>
                        <Trigger Property="TabStripPlacement" Value="Bottom">
                            <Setter TargetName="HeaderPanel" Property="Grid.Row" Value="1" />
                            <Setter TargetName="OverflowButton" Property="Grid.Row" Value="1" />
                            <Setter TargetName="Border" Property="Grid.Row" Value="0" />
                            <Setter TargetName="RowDefinition0" Property="Height" Value="*" />
                            <Setter TargetName="RowDefinition1" Property="Height" Value="Auto" />
                            <Setter TargetName="Border" Property="BorderThickness" Value="0,0,0,2" />
                        </Trigger>
                        <Trigger Property="TabStripPlacement" Value="Left">
                            <Setter TargetName="OverflowButton" Property="Grid.Row" Value="1" />
                            <Setter TargetName="OverflowButton" Property="Grid.Column" Value="0" />
                            <Setter TargetName="Border" Property="Grid.Row" Value="0" />
                            <Setter TargetName="Border" Property="Grid.RowSpan" Value="2" />
                            <Setter TargetName="Border" Property="Grid.Column" Value="1" />
                            <Setter TargetName="RowDefinition0" Property="Height" Value="*" />
                            <Setter TargetName="RowDefinition1" Property="Height" Value="Auto" />
                            <Setter TargetName="ColumnDefinition0" Property="Width" Value="Auto" />
                            <Setter TargetName="ColumnDefinition1" Property="Width" Value="*" />
                            <Setter TargetName="Border" Property="BorderThickness" Value="2,0,0,0" />
                            <Setter TargetName="HeaderPanel" Property="Orientation" Value="Vertical" />
                            <Setter TargetName="HeaderPanel" Property="Margin" Value="0,0,0,0" />
                        </Trigger>
                        <Trigger Property="localUI:ChromeTab.ShowOverflowButton" Value="false">
                            <Setter TargetName="OverflowButton" Property="Visibility" Value="Collapsed" />
                        </Trigger>
                        <Trigger Property="localUI:ChromeTab.ShowTabStrip" Value="False">
                            <Setter TargetName="HeaderPanel" Property="Visibility" Value="Collapsed" />
                            <Setter TargetName="Border" Property="BorderThickness" Value="0,0,0,0" />
                            <Setter TargetName="OverflowButton" Property="Visibility" Value="Collapsed" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>    

</ResourceDictionary>